
import re

def url_SlashEscape(url):
    return url.replace("\\/\\/", "//").replace("\\/", "/")

# r'((href|src|url|picUrl|data-url)(\"|\')([^(\"|\')]*?)\.(jpg|gif|png|jpeg)(\"|\'))'
# r'((http:|https:)([^(\"|\')]*?)\.(jpg|gif|png|jpeg))'
def re_PicUrls(html, reg = r'((href|src|url|picUrl|data-url)=(\"|\')([^(\"|\')]*?)\.(jpg|jpeg|gif|png)(\"|\'))'):
    imgre = re.compile(reg)
    imglist = re.findall(imgre, html)
    resultlist = []
    for img in imglist:
        imgUrl = img[0]
        imgUrl = str(imgUrl[imgUrl.index("=") + 2:len(imgUrl) - 1])
        if (not(imgUrl.startswith("http://")) and not(imgUrl.startswith("https://"))):
            if (imgUrl.startswith("//")):
                imgUrl = "http:" + imgUrl
            else:
                imgUrl = "http://" + imgUrl
        resultlist.append(imgUrl)
    return resultlist